import JSEncrypt from './JSEncrypt.js'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDFd/uYvAlDR4NyQQKOVb3mEZvgiuJ7qx5ZA9s8lNMnaWVtnoqDzqgGOFVhTQG3GPHAL6h8mTmU+6ucK3dP1XqIuAYdzKf/6ahqDOnscZ3vlCCaPCP7SSWDG0VH0Gx1Z3BSffjYj1oCkXUiqXgF+38UVCkf9XvBEgNA+vs21eVnJQIDAQAB'

const privateKey = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMV3+5i8CUNHg3JBAo5VveYRm+CK4nurHlkD2zyU0ydpZW2eioPOqAY4VWFNAbcY8cAvqHyZOZT7q5wrd0/Veoi4Bh3Mp//pqGoM6exxne+UIJo8I/tJJYMbRUfQbHVncFJ9+NiPWgKRdSKpeAX7fxRUKR/1e8ESA0D6+zbV5WclAgMBAAECgYEAiKMxMMpMDoXZaqGZRywFLsFYftMbTD9nzGhit1Szlz3StTtS1UmV8lfgnGdQnIViIn3Xs//CXFiYsoNRF6i8E87yEUvI/H9BIj2jr7aMnmlsKkIvQknwtDicy4q6td8z/SBtJKBq4YugdIuE6h4Z8UHirbciDbftwWz8/n3VqoECQQDqomDlEmfayJI5cRHO0Tv5iyVL30k7umThEfPNcaNkZof+Rz2Cb0ftNbhTK1jy/vWTYIqKbBf0OwmUyQZL/455AkEA13M6IMTasWzgB6VO6kQxxkkz6i99RiW8vPA3fp7G77iWj3FEQ1zAbkSbp2yvudQDDBde65IPiEEP2DGJpk3DDQJAE964ce3DGcYOjArFRUx21cUw3WIFY6d/T4gjq2xKOABu19vUm60s3CvGdlSfbcSlq1troBlTVf2B7DWx8NGtkQJATcSh7sIfzntmQlxBJ/6FmPVDb/zEU1W70tdCsMnPNSiD8DMKWOZZ73OEW+K3a3RDxVGKSa3nPV9+wKLg9M6M4QJAVIvumeASJdRzMjwbyzxrzSBmN0U1XYlHVybf/RdGcIS6XC8IPrtIb4jFSYfRnqKXMYc+viNnHfBEVSyKFsYQAA=='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

